package com.xx.sg.handler;

import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.reader.ObjectReader;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

public class TimestampToLocalDateTimeReader implements ObjectReader<LocalDateTime> {
    @Override
    public LocalDateTime readObject(JSONReader reader, java.lang.reflect.Type fieldType, Object fieldName, long features) {
        long timestamp = reader.readInt64();  // 如果是秒记得 *1000
        return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
    }
}
